﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 观察者模式.Observer;
using 观察者模式.Subject;

namespace 观察者模式
{
    /// <summary>
    /// 1 观察者模式Observer
    /// 2 .net的委托事件
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            Cat cat = new Cat();
            cat.Miao();


            Console.WriteLine("***************Observer*****************");

            cat.AddObserver(new Baby());
            cat.AddObserver(new Dog());
            cat.AddObserver(new Father());
            cat.AddObserver(new Mother());

            cat.MiaoObserver();


            Console.WriteLine("*************Event***************");
            cat.MiaoEvent+=new Baby().Cry;
            cat.MiaoEvent+=new Dog().Wang;
            cat.MiaoEvent+=new Father().Roar;
            cat.MiaoEvent+=new Mother().Whisper;
            cat.MiaoEvent1();

            Console.Read();
        }
    }
}
